<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="false"
      label-width="68px"
    >
      <el-form-item label="退货单号" prop="returnOrderId">
        <el-input
          v-model="queryParams.returnOrderId"
          placeholder="请输入退货单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="外部单号" prop="externalOrderId">
        <el-input
          v-model="queryParams.externalOrderId"
          placeholder="请输入外部单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="退货日期" prop="returnDate">
        <el-date-picker
          clearable
          v-model="queryParams.returnDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择退货日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="仓库" prop="warehouse">
        <el-input
          v-model="queryParams.warehouse"
          placeholder="请输入仓库"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="标记多标签" prop="multipleLabels">
          <el-input
            v-model="queryParams.multipleLabels"
            placeholder="请输入标记多标签"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商" prop="supplier">
          <el-input
            v-model="queryParams.supplier"
            placeholder="选择供应商"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="创建人" prop="creator">
          <el-input
            v-model="queryParams.creator"
            placeholder="请输入创建人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="财审人" prop="auditor">
          <el-input
            v-model="queryParams.auditor"
            placeholder="请输入财审人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="财审日期" prop="auditDate">
          <el-date-picker
            clearable
            v-model="queryParams.auditDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择财审日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="采购单号" prop="purchaseOrderNumber">
          <el-input
            v-model="queryParams.purchaseOrderNumber"
            placeholder="请输入采购单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="拣货批次" prop="batchNumber">
          <el-input
            v-model="queryParams.batchNumber"
            placeholder="请输入拣货批次"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物流公司" prop="logisticsCompany">
          <el-input
            v-model="queryParams.logisticsCompany"
            placeholder="请输入物流公司"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物流单号" prop="logisticsNumber">
          <el-input
            v-model="queryParams.logisticsNumber"
            placeholder="请输入物流单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="创建日期" prop="creationDate">
          <el-date-picker
            clearable
            v-model="queryParams.creationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择创建日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最后修改日期" prop="lastModificationDate">
          <el-date-picker
            clearable
            v-model="queryParams.lastModificationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最后修改日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="操作仓储方" prop="storageOperator">
          <el-input
            v-model="queryParams.storageOperator"
            placeholder="请输入操作仓储方"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="图片" prop="productImageUrl">
          <el-input
            v-model="queryParams.productImageUrl"
            placeholder="请输入图片"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品标签" prop="productLabel">
          <el-input
            v-model="queryParams.productLabel"
            placeholder="请输入商品标签"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品编码" prop="productCode">
          <el-input
            v-model="queryParams.productCode"
            placeholder="请输入商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品名称" prop="productName">
          <el-input
            v-model="queryParams.productName"
            placeholder="请输入商品名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="颜色及规格" prop="colorSpecification">
          <el-input
            v-model="queryParams.colorSpecification"
            placeholder="请输入颜色及规格"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="退货数量" prop="returnQuantity">
          <el-input
            v-model="queryParams.returnQuantity"
            placeholder="请输入退货数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input
            v-model="queryParams.unit"
            placeholder="请输入单位"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input
            v-model="queryParams.unitPrice"
            placeholder="请输入单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="金额" prop="totalAmount">
          <el-input
            v-model="queryParams.totalAmount"
            placeholder="请输入金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="基本售价" prop="basicSellingPrice">
          <el-input
            v-model="queryParams.basicSellingPrice"
            placeholder="请输入基本售价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="基本销售额" prop="salesVolume">
          <el-input
            v-model="queryParams.salesVolume"
            placeholder="请输入基本销售额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="税率" prop="taxRate">
          <el-input
            v-model="queryParams.taxRate"
            placeholder="请输入税率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="明细税率" prop="detailedTaxRate">
          <el-input
            v-model="queryParams.detailedTaxRate"
            placeholder="请输入明细税率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="不含税单价" prop="taxExclusiveUnitPrice">
          <el-input
            v-model="queryParams.taxExclusiveUnitPrice"
            placeholder="请输入不含税单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="不含税金额" prop="taxExclusiveTotalAmount">
          <el-input
            v-model="queryParams.taxExclusiveTotalAmount"
            placeholder="请输入不含税金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="款式编号" prop="styleNumber">
          <el-input
            v-model="queryParams.styleNumber"
            placeholder="请输入款式编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商款号" prop="supplierStyleNumber">
          <el-input
            v-model="queryParams.supplierStyleNumber"
            placeholder="选择供应商款号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商商品编码" prop="supplierProductCode">
          <el-input
            v-model="queryParams.supplierProductCode"
            placeholder="选择供应商商品编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="体积" prop="volume">
          <el-input
            v-model="queryParams.volume"
            placeholder="请输入体积"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="重量" prop="weight">
          <el-input
            v-model="queryParams.weight"
            placeholder="请输入重量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="年" prop="dataMonth">
          <el-input
            v-model="queryParams.dataMonth"
            placeholder="请输入年"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="月" prop="dataYear">
          <el-input
            v-model="queryParams.dataYear"
            placeholder="请输入月"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['purchase:PurchaseReturn:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['purchase:PurchaseReturn:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['purchase:PurchaseReturn:remove']"
          >删除</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['purchase:PurchaseReturn:export']"
          >导出</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-upload" @click="daoru"
          >导入</el-button
        >
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="PurchaseReturnList"
      @selection-change="handleSelectionChange"
      :height="680"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column width="120" label="id" align="center" prop="id" />
      <el-table-column
        width="120"
        label="退货单号"
        align="center"
        prop="returnOrderId"
      />
      <el-table-column
        width="120"
        label="外部单号"
        align="center"
        prop="externalOrderId"
      />
      <el-table-column
        width="120"
        label="退货日期"
        align="center"
        prop="returnDate"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.returnDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column width="120" label="状态" align="center" prop="status" />
      <el-table-column width="120" label="仓库" align="center" prop="warehouse">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="bottom" width="300">
            <!-- <span>{{ scope.row.fabricComposition }}</span> -->
            <el-input
              v-model="scope.row.warehouse"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">
                {{ scope.row.warehouse }}
              </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="标记多标签"
        align="center"
        prop="multipleLabels"
      />
      <el-table-column
        width="120"
        label="供应商"
        align="center"
        prop="supplier"
      />
      <el-table-column
        width="120"
        label="创建人"
        align="center"
        prop="creator"
      />
      <el-table-column
        width="120"
        label="财审人"
        align="center"
        prop="auditor"
      />
      <el-table-column
        width="120"
        label="财审日期"
        align="center"
        prop="auditDate"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.auditDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="采购单号"
        align="center"
        prop="purchaseOrderNumber"
      />
      <el-table-column
        width="120"
        label="拣货批次"
        align="center"
        prop="batchNumber"
      />
      <el-table-column
        width="120"
        label="退货单备注"
        align="center"
        prop="returnRemark"
      >
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="bottom" width="300">
            <!-- <span>{{ scope.row.fabricComposition }}</span> -->
            <el-input
              v-model="scope.row.returnRemark"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">
                {{ scope.row.returnRemark }}
              </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="物流公司"
        align="center"
        prop="logisticsCompany"
      />
      <el-table-column
        width="120"
        label="物流单号"
        align="center"
        prop="logisticsNumber"
      />
      <el-table-column
        width="120"
        label="创建日期"
        align="center"
        prop="creationDate"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.creationDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="最后修改日期"
        align="center"
        prop="lastModificationDate"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.lastModificationDate, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="操作仓储方"
        align="center"
        prop="storageOperator"
      />
      <el-table-column
        width="120"
        label="图片"
        align="center"
        prop="productImageUrl"
      >
        <template slot-scope="scope">
          <image-preview
            :src="scope.row.productImageUrl"
            :width="30"
            :height="30"
          />
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="商品标签"
        align="center"
        prop="productLabel"
      />
      <el-table-column
        width="120"
        label="商品编码"
        align="center"
        prop="productCode"
      />
      <el-table-column
        width="120"
        label="商品名称"
        align="center"
        prop="productName"
      />
      <el-table-column
        width="120"
        label="颜色及规格"
        align="center"
        prop="colorSpecification"
      />
      <el-table-column
        width="120"
        label="退货数量"
        align="center"
        prop="returnQuantity"
      />
      <el-table-column width="120" label="单位" align="center" prop="unit" />
      <el-table-column
        width="120"
        label="单价"
        align="center"
        prop="unitPrice"
      />
      <el-table-column
        width="120"
        label="金额"
        align="center"
        prop="totalAmount"
      />
      <el-table-column
        width="120"
        label="基本售价"
        align="center"
        prop="basicSellingPrice"
      />
      <el-table-column
        width="120"
        label="基本销售额"
        align="center"
        prop="salesVolume"
      />
      <el-table-column width="120" label="税率" align="center" prop="taxRate" />
      <el-table-column
        width="120"
        label="明细税率"
        align="center"
        prop="detailedTaxRate"
      />
      <el-table-column
        width="120"
        label="不含税单价"
        align="center"
        prop="taxExclusiveUnitPrice"
      />
      <el-table-column
        width="120"
        label="不含税金额"
        align="center"
        prop="taxExclusiveTotalAmount"
      />
      <el-table-column
        width="120"
        label="款式编号"
        align="center"
        prop="styleNumber"
      />
      <el-table-column
        width="120"
        label="供应商款号"
        align="center"
        prop="supplierStyleNumber"
      />
      <el-table-column
        width="120"
        label="供应商商品编码"
        align="center"
        prop="supplierProductCode"
      />
      <el-table-column
        width="120"
        label="明细备注"
        align="center"
        prop="detailRemark"
      />
      <el-table-column width="120" label="体积" align="center" prop="volume" />
      <el-table-column width="120" label="重量" align="center" prop="weight" />
      <el-table-column width="120" label="年" align="center" prop="dataYear" />
      <el-table-column width="120" label="月" align="center" prop="dataMonth" />
      <!-- <el-table-column
        width="120"
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['purchase:PurchaseReturn:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['purchase:PurchaseReturn:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改供应商采购退货对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="退货单号" prop="returnOrderId">
          <el-input v-model="form.returnOrderId" placeholder="请输入退货单号" />
        </el-form-item>
        <el-form-item label="外部单号" prop="externalOrderId">
          <el-input
            v-model="form.externalOrderId"
            placeholder="请输入外部单号"
          />
        </el-form-item>
        <el-form-item label="退货日期" prop="returnDate">
          <el-date-picker
            clearable
            v-model="form.returnDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择退货日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="仓库" prop="warehouse">
          <el-input v-model="form.warehouse" placeholder="请输入仓库" />
        </el-form-item>
        <el-form-item label="标记多标签" prop="multipleLabels">
          <el-input
            v-model="form.multipleLabels"
            placeholder="请输入标记多标签"
          />
        </el-form-item>
        <el-form-item label="供应商" prop="supplier">
          <el-input v-model="form.supplier" placeholder="选择供应商" />
        </el-form-item>
        <el-form-item label="创建人" prop="creator">
          <el-input v-model="form.creator" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="财审人" prop="auditor">
          <el-input v-model="form.auditor" placeholder="请输入财审人" />
        </el-form-item>
        <el-form-item label="财审日期" prop="auditDate">
          <el-date-picker
            clearable
            v-model="form.auditDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择财审日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="采购单号" prop="purchaseOrderNumber">
          <el-input
            v-model="form.purchaseOrderNumber"
            placeholder="请输入采购单号"
          />
        </el-form-item>
        <el-form-item label="拣货批次" prop="batchNumber">
          <el-input v-model="form.batchNumber" placeholder="请输入拣货批次" />
        </el-form-item>
        <el-form-item label="退货单备注" prop="returnRemark">
          <el-input
            v-model="form.returnRemark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="物流公司" prop="logisticsCompany">
          <el-input
            v-model="form.logisticsCompany"
            placeholder="请输入物流公司"
          />
        </el-form-item>
        <el-form-item label="物流单号" prop="logisticsNumber">
          <el-input
            v-model="form.logisticsNumber"
            placeholder="请输入物流单号"
          />
        </el-form-item>
        <el-form-item label="创建日期" prop="creationDate">
          <el-date-picker
            clearable
            v-model="form.creationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择创建日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="最后修改日期" prop="lastModificationDate">
          <el-date-picker
            clearable
            v-model="form.lastModificationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最后修改日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="操作仓储方" prop="storageOperator">
          <el-input
            v-model="form.storageOperator"
            placeholder="请输入操作仓储方"
          />
        </el-form-item>
        <el-form-item label="图片" prop="productImageUrl">
          <el-input v-model="form.productImageUrl" placeholder="请输入图片" />
        </el-form-item>
        <el-form-item label="商品标签" prop="productLabel">
          <el-input v-model="form.productLabel" placeholder="请输入商品标签" />
        </el-form-item>
        <el-form-item label="商品编码" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入商品编码" />
        </el-form-item>
        <el-form-item label="商品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入商品名称" />
        </el-form-item>
        <el-form-item label="颜色及规格" prop="colorSpecification">
          <el-input
            v-model="form.colorSpecification"
            placeholder="请输入颜色及规格"
          />
        </el-form-item>
        <el-form-item label="退货数量" prop="returnQuantity">
          <el-input
            v-model="form.returnQuantity"
            placeholder="请输入退货数量"
          />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="form.unitPrice" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="金额" prop="totalAmount">
          <el-input v-model="form.totalAmount" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="基本售价" prop="basicSellingPrice">
          <el-input
            v-model="form.basicSellingPrice"
            placeholder="请输入基本售价"
          />
        </el-form-item>
        <el-form-item label="基本销售额" prop="salesVolume">
          <el-input v-model="form.salesVolume" placeholder="请输入基本销售额" />
        </el-form-item>
        <el-form-item label="税率" prop="taxRate">
          <el-input v-model="form.taxRate" placeholder="请输入税率" />
        </el-form-item>
        <el-form-item label="明细税率" prop="detailedTaxRate">
          <el-input
            v-model="form.detailedTaxRate"
            placeholder="请输入明细税率"
          />
        </el-form-item>
        <el-form-item label="不含税单价" prop="taxExclusiveUnitPrice">
          <el-input
            v-model="form.taxExclusiveUnitPrice"
            placeholder="请输入不含税单价"
          />
        </el-form-item>
        <el-form-item label="不含税金额" prop="taxExclusiveTotalAmount">
          <el-input
            v-model="form.taxExclusiveTotalAmount"
            placeholder="请输入不含税金额"
          />
        </el-form-item>
        <el-form-item label="款式编号" prop="styleNumber">
          <el-input v-model="form.styleNumber" placeholder="请输入款式编号" />
        </el-form-item>
        <el-form-item label="供应商款号" prop="supplierStyleNumber">
          <el-input
            v-model="form.supplierStyleNumber"
            placeholder="选择供应商款号"
          />
        </el-form-item>
        <el-form-item label="供应商商品编码" prop="supplierProductCode">
          <el-input
            v-model="form.supplierProductCode"
            placeholder="选择供应商商品编码"
          />
        </el-form-item>
        <el-form-item label="明细备注" prop="detailRemark">
          <el-input
            v-model="form.detailRemark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="体积" prop="volume">
          <el-input v-model="form.volume" placeholder="请输入体积" />
        </el-form-item>
        <el-form-item label="重量" prop="weight">
          <el-input v-model="form.weight" placeholder="请输入重量" />
        </el-form-item>
        <el-form-item label="年" prop="dataMonth">
          <el-input v-model="form.dataMonth" placeholder="请输入年" />
        </el-form-item>
        <el-form-item label="月" prop="dataYear">
          <el-input v-model="form.dataYear" placeholder="请输入月" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="500px"
      append-to-body
      v-if="dialogVisible"
    >
      <el-upload
        :action="Upload.url"
        :headers="Upload.headers"
        :limit="limit"
        :on-exceed="handleExceed"
        :on-success="handlePictureSuccessPic"
        :before-upload="beforeAvatarUpload"
        :on-preview="handlePictureCardPreview"
        :file-list="fileLi"
        :on-change="changeFile1"
      >
        <el-button size="small" type="primary">导入文件</el-button>
        <!-- <i class="el-icon-plus"></i> -->
      </el-upload>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPurchaseReturn,
  getPurchaseReturn,
  delPurchaseReturn,
  addPurchaseReturn,
  updatePurchaseReturn,
} from "@/api/purchase/PurchaseReturn";
//--------导入token
import { getToken } from "@/utils/auth";
export default {
  name: "PurchaseReturn",
  props: {
    query: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      pjtUrl: process.env.VUE_APP_BASE_API,

      fileLi: [],
      file: "",
      dialogVisible: false,
      // 图片数量限制
      limit: 2,
      Upload: {
        // 设置上传的请求头部
        headers: {
          Authorization: "Bearer " + getToken(),
        },
        // 图片上传的方法地址:
        url:
          process.env.VUE_APP_BASE_API + "/purchase/PurchaseReturn/importData",
      },
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 供应商采购退货表格数据
      PurchaseReturnList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        returnOrderId: null,
        externalOrderId: null,
        returnDate: null,
        status: null,
        warehouse: null,
        multipleLabels: null,
        supplier: null,
        creator: null,
        auditor: null,
        auditDate: null,
        purchaseOrderNumber: null,
        batchNumber: null,
        returnRemark: null,
        logisticsCompany: null,
        logisticsNumber: null,
        creationDate: null,
        lastModificationDate: null,
        storageOperator: null,
        productImageUrl: null,
        productLabel: null,
        productCode: null,
        productName: null,
        colorSpecification: null,
        returnQuantity: null,
        unit: null,
        unitPrice: null,
        totalAmount: null,
        basicSellingPrice: null,
        salesVolume: null,
        taxRate: null,
        detailedTaxRate: null,
        taxExclusiveUnitPrice: null,
        taxExclusiveTotalAmount: null,
        styleNumber: null,
        supplierStyleNumber: null,
        supplierProductCode: null,
        detailRemark: null,
        volume: null,
        weight: null,
        dataMonth: null,
        dataYear: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.queryParams = this.query;
    this.getList();
  },
  methods: {
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询供应商采购退货列表 */
    getList() {
      this.loading = true;
      listPurchaseReturn(this.queryParams).then((response) => {
        this.PurchaseReturnList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        returnOrderId: null,
        externalOrderId: null,
        returnDate: null,
        status: null,
        warehouse: null,
        multipleLabels: null,
        supplier: null,
        creator: null,
        auditor: null,
        auditDate: null,
        purchaseOrderNumber: null,
        batchNumber: null,
        returnRemark: null,
        logisticsCompany: null,
        logisticsNumber: null,
        creationDate: null,
        lastModificationDate: null,
        storageOperator: null,
        productImageUrl: null,
        productLabel: null,
        productCode: null,
        productName: null,
        colorSpecification: null,
        returnQuantity: null,
        unit: null,
        unitPrice: null,
        totalAmount: null,
        basicSellingPrice: null,
        salesVolume: null,
        taxRate: null,
        detailedTaxRate: null,
        taxExclusiveUnitPrice: null,
        taxExclusiveTotalAmount: null,
        styleNumber: null,
        supplierStyleNumber: null,
        supplierProductCode: null,
        detailRemark: null,
        volume: null,
        weight: null,
        dataMonth: null,
        dataYear: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加供应商采购退货";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPurchaseReturn(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改供应商采购退货";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updatePurchaseReturn(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPurchaseReturn(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除供应商采购退货编号为"' + ids + '"的数据项？')
        .then(function () {
          return delPurchaseReturn(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "purchase/PurchaseReturn/export",
        {
          ...this.queryParams,
        },
        `PurchaseReturn_${new Date().getTime()}.xlsx`
      );
    },
    //部门文件导入修改打开
    daoru() {
      this.dialogVisible = true;
    },
    // 打开加载层
    openUploadLoading() {
      this.$modal.loading("正在导入，请稍候！");
    },
    //文件导入成功回传

    handlePictureSuccessPic(res, file) {
      console.log(JSON.stringify(res));
      //设置图片访问路径 （url 后台传过来的的上传地址）
      // this.picUrl = file.response.url;
      // const url = file.response.fileName;
      this.file = file.response.url;
      console.log(JSON.stringify(this.file));
      if (res.code == 200) {
        this.dialogVisible = false;
        this.$modal.closeLoading();
        this.$modal.msgSuccess(res.msg);
        // if (res.msg == "操作成功") {
        //   this.$modal.msgSuccess("导入成功");
        // } else {
        //   this.$modal.msgError(res.msg);
        // }
        this.getList();
        // return true
      } else {
        this.$modal.msgError(res.msg);
        this.dialogVisible = true;
        // this.$message.msgError('该颜色未在字典定义')
        return;
      }
    },
    //图片预览
    handlePictureCardPreview(file) {
      // this.picUrl = file.url
      // this.imageUrl = file.url;
      // this.dialogVisible = true;
    },
    //图片上传前的相关判断
    beforeAvatarUpload(file) {
      // const isJPG = file.type == 'image/jpeg' || file.type == 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 100;
      // if (!isJPG) {
      //     this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
      // }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 100MB!");
      }
      this.openUploadLoading();
      return isLt2M;
    },

    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传链接文件数量不能超过 ${this.limit} 个!`);
    },
    // 上传文件让第二次覆盖第一的文件
    changeFile1(file, fileList) {
      if (fileList.length > 1) {
        this.fileLi = fileList.slice(-1);

        // this.fileList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
      }
      // this.fileSpecial = fileList;
    },
  },
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  height: 80vh;
  overflow-x: hidden;
}

.el-input.is-disabled ::v-deep .el-input__inner {
  color: #606266;
  background-color: white;
  border: none;
}

.el-textarea.is-disabled ::v-deep .el-textarea__inner {
  color: #606266;
  background-color: white;
  border: none;
  width: 500px;
  resize: none;
  cursor: pointer;
}

span.textname {
  display: -webkit-box;

  text-overflow: ellipsis;
  overflow: hidden;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}
</style>